//// Source code recreated from a .class file by IntelliJ IDEA// (powered by FernFlower decompiler)//package com.app.twth.satoprinter;import android.content.Context;import android.graphics.Bitmap;import android.graphics.Bitmap.Config;import android.graphics.BitmapFactory;import android.graphics.BitmapFactory.Options;import android.hardware.usb.UsbDevice;import android.os.Environment;import android.os.Handler;import android.os.Looper;import android.util.Log;import com.app.twth.satoprinter.print.BitmapManager;import com.app.twth.satoprinter.print.RunLengthEncoding;import com.app.twth.satoprinter.property.CodePageManager;import com.app.twth.satoprinter.service.ServiceManager;import com.app.twth.satoprinter.utility.Command;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.nio.ByteBuffer;public class Printer {    public static final String TAG = "LabelPrinter";    public static final boolean D = false;    public static final String SDK_VERSION = "V1.0.0";    public static final int MESSAGE_STATE_CHANGE = 1;    public static final int MESSAGE_READ = 2;    public static final int MESSAGE_WRITE = 3;    public static final int MESSAGE_DEVICE_NAME = 4;    public static final int MESSAGE_TOAST = 5;    public static final int MESSAGE_LOG = 6;    public static final int MESSAGE_BLUETOOTH_DEVICE_SET = 7;    public static final int MESSAGE_USB_DEVICE_SET = 10;    public static final int MESSAGE_NETWORK_DEVICE_SET = 12;    public static final int MESSAGE_OUTPUT_COMPLETE = 13;    public static final int MESSAGE_PRINTER_INCH = 20;    public static boolean MESSAGE_CHECKED_MODEL_NAME = false;    public static final int STATE_NONE = 0;    public static final int STATE_CONNECTING = 1;    public static final int STATE_CONNECTED = 2;    public static final String DEVICE_NAME = "device_name";    public static final String TOAST = "toast";    public static final String LOG = "log";    public static final int STATUS_NORMAL = 0;    public static final int STATUS_1ST_BYTE_PAPER_EMPTY = -128;    public static final int STATUS_1ST_BYTE_COVER_OPEN = 64;    public static final int STATUS_1ST_BYTE_CUTTER_JAMMED = 32;    public static final int STATUS_1ST_BYTE_TPH_OVERHEAT = 16;    public static final int STATUS_1ST_BYTE_AUTO_SENSING_FAILURE = 8;    public static final int STATUS_1ST_BYTE_RIBBON_END_ERROR = 4;    public static final int STATUS_2ND_BYTE_BUILDING_IN_IMAGE_BUFFER = -128;    public static final int STATUS_2ND_BYTE_PRINTING_IN_IMAGE_BUFFER = 64;    public static final int STATUS_2ND_BYTE_PAUSED_IN_PEELER_UNIT = 32;    public static final int PROCESS_NONE = 0;    public static final int PROCESS_RESPONSE = 1;    public static final int PROCESS_GET_STATUS = 2;    public static final int PROCESS_GET_STATUS_1BYTE = 3;    public static final int PROCESS_GET_STATUS_2BYTE = 4;    public static final int PROCESS_GET_INFORMATION_MODEL_NAME = 5;    public static final int PROCESS_GET_INFORMATION_FIRMWARE_VERSION = 6;    public static final int PROCESS_EXECUTE_DIRECT_IO = 7;    public static final int PROESS_CONNECTED = 8;    public static final int PROESS_OUTPUT_COMPLETE = 9;    private ServiceManager mServiceManager;    private Context mContext;    private static boolean isSaveBinary = false;    public static final int BLUETOOTH_CLASSIC = 0;    public static final int BLUETOOTH_LOW_ENERGY = 1;    public static final int FONT_SIZE_6 = 48;    public static final int FONT_SIZE_8 = 49;    public static final int FONT_SIZE_10 = 50;    public static final int FONT_SIZE_12 = 51;    public static final int FONT_SIZE_15 = 52;    public static final int FONT_SIZE_20 = 53;    public static final int FONT_SIZE_30 = 54;    public static final int FONT_SIZE_14 = 55;    public static final int FONT_SIZE_18 = 56;    public static final int FONT_SIZE_24 = 57;    public static final int FONT_SIZE_KOREAN1 = 97;    public static final int FONT_SIZE_KOREAN2 = 98;    public static final int FONT_SIZE_KOREAN3 = 99;    public static final int FONT_SIZE_KOREAN4 = 100;    public static final int FONT_SIZE_KOREAN5 = 101;    public static final int FONT_SIZE_KOREAN6 = 102;    public static final int FONT_SIZE_GB2312 = 109;    public static final int FONT_SIZE_BIG5 = 110;    public static final int FONT_SIZE_SHIFT_JIS = 106;    public static final int ROTATION_NONE = 0;    public static final int ROTATION_90_DEGREES = 1;    public static final int ROTATION_180_DEGREES = 2;    public static final int ROTATION_270_DEGREES = 3;    public static final int TEXT_ALIGNMENT_NONE = 48;    public static final int TEXT_ALIGNMENT_LEFT = 70;    public static final int TEXT_ALIGNMENT_RIGHT = 76;    public static final int TEXT_ALIGNMENT_RIGHT_TO_LEFT = 82;    public static final int VECTOR_FONT_ASCII = 85;    public static final int VECTOR_FONT_KS5601 = 75;    public static final int VECTOR_FONT_BIG5 = 66;    public static final int VECTOR_FONT_GB2312 = 71;    public static final int VECTOR_FONT_SHIFT_JIS = 74;    public static final int VECTOR_FONT_OCR_A = 97;    public static final int VECTOR_FONT_OCR_B = 98;    public static final int VECTOR_FONT_TEXT_DIRECTION_LEFT_TO_RIGHT = 0;    public static final int VECTOR_FONT_TEXT_DIRECTION_RIGHT_TO_LEET = 1;    public static final int VECTOR_FONT_TEXT_ALIGNMENT_LEFT = 76;    public static final int VECTOR_FONT_TEXT_ALIGNMENT_RIGHT = 82;    public static final int VECTOR_FONT_TEXT_ALIGNMENT_CENTER = 67;    public static final int BARCODE_CODE39 = 0;    public static final int BARCODE_CODE128 = 1;    public static final int BARCODE_I2OF5 = 2;    public static final int BARCODE_CODABAR = 3;    public static final int BARCODE_CODE93 = 4;    public static final int BARCODE_UPC_A = 5;    public static final int BARCODE_UPC_E = 6;    public static final int BARCODE_EAN13 = 7;    public static final int BARCODE_EAN8 = 8;    public static final int BARCODE_UCC_EAN128 = 9;    public static final int BARCODE_CODE11 = 10;    public static final int BARCODE_PLANET = 11;    public static final int BARCODE_INDUSTRIAL_2OF5 = 12;    public static final int BARCODE_STANDARD_2OF5 = 13;    public static final int BARCODE_LOGMARS = 14;    public static final int BARCODE_UPC_EAN_EXTENSIONS = 15;    public static final int BARCODE_POSTNET = 16;    public static final int HRI_NOT_PRINTED = 0;    public static final int HRI_BELOW_FONT_SIZE_1 = 1;    public static final int HRI_ABOVE_FONT_SIZE_1 = 2;    public static final int HRI_BELOW_FONT_SIZE_2 = 3;    public static final int HRI_ABOVE_FONT_SIZE_2 = 4;    public static final int HRI_BELOW_FONT_SIZE_3 = 5;    public static final int HRI_ABOVE_FONT_SIZE_3 = 6;    public static final int HRI_BELOW_FONT_SIZE_4 = 7;    public static final int HRI_ABOVE_FONT_SIZE_4 = 8;    public static final int MAXICODE_MODE0 = 0;    public static final int MAXICODE_MODE2 = 2;    public static final int MAXICODE_MODE3 = 3;    public static final int MAXICODE_MODE4 = 4;    public static final int PDF417_ERROR_CORRECTION_LEVEL0 = 0;    public static final int PDF417_ERROR_CORRECTION_LEVEL1 = 1;    public static final int PDF417_ERROR_CORRECTION_LEVEL2 = 2;    public static final int PDF417_ERROR_CORRECTION_LEVEL3 = 3;    public static final int PDF417_ERROR_CORRECTION_LEVEL4 = 4;    public static final int PDF417_ERROR_CORRECTION_LEVEL5 = 5;    public static final int PDF417_ERROR_CORRECTION_LEVEL6 = 6;    public static final int PDF417_ERROR_CORRECTION_LEVEL7 = 7;    public static final int PDF417_ERROR_CORRECTION_LEVEL8 = 8;    public static final int DATA_COMPRESSION_TEXT = 0;    public static final int DATA_COMPRESSION_NUMERIC = 1;    public static final int DATA_COMPRESSION_BINARY = 2;    public static final int PDF417_HRI_NOT_PRINTED = 0;    public static final int PDF417_HRI_BELOW_BARCODE = 1;    public static final int BARCODE_ORIGIN_POINT_CENTER = 0;    public static final int BARCODE_ORIGIN_POINT_UPPER_LEFT = 1;    public static final int QR_CODE_MODEL1 = 1;    public static final int QR_CODE_MODEL2 = 2;    public static final int ECC_LEVEL_7 = 76;    public static final int ECC_LEVEL_15 = 77;    public static final int ECC_LEVEL_25 = 81;    public static final int ECC_LEVEL_30 = 72;    public static final int CODE49_HRI_NOT_PRINTED = 0;    public static final int CODE49_HRI_BELOW_BARCODE = 1;    public static final int CODE49_HRI_ABOVE_BARCODE = 2;    public static final int CODE49_STRING_MODE_REGULAR_ALPHANUMERIC = 0;    public static final int CODE49_STRING_MODE_MULTIPLE_READ_ALPHANUMERIC = 1;    public static final int CODE49_STRING_MODE_REGULAR_NUMERIC = 2;    public static final int CODE49_STRING_MODE_GROUP_ALPHANUMERIC = 3;    public static final int CODE49_STRING_MODE_REGULAR_ALPHANUMERIC_SHIFT1 = 4;    public static final int CODE49_STRING_MODE_REGULAR_ALPHANUMERIC_SHIFT2 = 5;    public static final int CODE49_STRING_MODE_AUTOMATIC_MODE = 7;    public static final char CODABLOCK_MODE_A = 'A';    public static final char CODABLOCK_MODE_E = 'E';    public static final char CODABLOCK_MODE_F = 'F';    public static final int MSI_BARCODE_CHECKDIGIT_NONE = 0;    public static final int MSI_BARCODE_CHECKDIGIT_1MOD10 = 1;    public static final int MSI_BARCODE_CHECKDIGIT_2MOD10 = 2;    public static final int MSI_BARCODE_CHECKDIGIT_1MOD11_AND_1MOD_10 = 3;    public static final int MSI_BARCODE_HRI_NOT_PRINTED = 0;    public static final int MSI_BARCODE_HRI_BELOW_BARCODE = 1;    public static final int MSI_BARCODE_HRI_ABOVE_BARCODE = 2;    public static final int PLESSEY_BARCODE_HRI_NOT_PRINTED = 0;    public static final int PLESSEY_BARCODE_HRI_BELOW_BARCODE = 1;    public static final int PLESSEY_BARCODE_HRI_ABOVE_BARCODE = 2;    public static final int BARCODE_TYPE_RSS14 = 0;    public static final int BARCODE_TYPE_RSS14_TRUNCATED = 1;    public static final int BARCODE_TYPE_RSS14_STACKED = 2;    public static final int BARCODE_TYPE_RSS14_STACKED_OMNIDIRECTIONAL = 3;    public static final int BARCODE_TYPE_RSS_LIMITIED = 4;    public static final int BARCODE_TYPE_RSS_EXPANDED = 5;    public static final int BARCODE_TYPE_RSS_UPCA = 6;    public static final int BARCODE_TYPE_RSS_UPCE = 7;    public static final int BARCODE_TYPE_RSS_EAN13 = 8;    public static final int BARCODE_TYPE_RSS_EAN8 = 9;    public static final int BARCODE_TYPE_RSS_UCC_EAN128_CCAB = 10;    public static final int BARCODE_TYPE_RSS_UCC_EAN128_CCC = 11;    public static final int BLOCK_OPTION_LINE_OVERWRITING = 79;    public static final int BLOCK_OPTION_LINE_EXCLUSIVE_OR = 69;    public static final int BLOCK_OPTION_LINE_DELETE = 68;    public static final int BLOCK_OPTION_SLOPE = 83;    public static final int BLOCK_OPTION_BOX = 66;    public static final int CIRCLE_SIZE_DIAMETER5 = 1;    public static final int CIRCLE_SIZE_DIAMETER7 = 2;    public static final int CIRCLE_SIZE_DIAMETER9 = 3;    public static final int CIRCLE_SIZE_DIAMETER11 = 4;    public static final int CIRCLE_SIZE_DIAMETER13 = 5;    public static final int CIRCLE_SIZE_DIAMETER21 = 6;    public static final int INTERNATIONAL_CHARACTER_SET_USA = 0;    public static final int INTERNATIONAL_CHARACTER_SET_FRANCE = 1;    public static final int INTERNATIONAL_CHARACTER_SET_GERMANY = 2;    public static final int INTERNATIONAL_CHARACTER_SET_UK = 3;    public static final int INTERNATIONAL_CHARACTER_SET_DENMARK1 = 4;    public static final int INTERNATIONAL_CHARACTER_SET_SWEDEN = 5;    public static final int INTERNATIONAL_CHARACTER_SET_ITALY = 6;    public static final int INTERNATIONAL_CHARACTER_SET_SPAIN1 = 7;    public static final int INTERNATIONAL_CHARACTER_SET_NORWAY = 8;    public static final int INTERNATIONAL_CHARACTER_SET_DENMARK2 = 9;    public static final int INTERNATIONAL_CHARACTER_SET_JAPAN = 10;    public static final int INTERNATIONAL_CHARACTER_SET_SPAIN2 = 11;    public static final int INTERNATIONAL_CHARACTER_SET_LATIN_AMERICA = 12;    public static final int INTERNATIONAL_CHARACTER_SET_KOREA = 13;    public static final int INTERNATIONAL_CHARACTER_SET_SLOVENIA_CROATIA = 14;    public static final int INTERNATIONAL_CHARACTER_SET_CHINA = 15;    public static final int CODE_PAGE_CP437_USA = 0;    public static final int CODE_PAGE_CP850_LATIN1 = 1;    public static final int CODE_PAGE_CP852_LATIN2 = 2;    public static final int CODE_PAGE_CP860_PORTUGUESE = 3;    public static final int CODE_PAGE_CP863_CANADIAN_FRENCH = 4;    public static final int CODE_PAGE_CP865_NORDIC = 5;    public static final int CODE_PAGE_WCP1252_LATIN1 = 6;    public static final int CODE_PAGE_CP865_WCP1252_EUROPEAN_COMBINED = 7;    public static final int CODE_PAGE_CP857_TURKISH = 8;    public static final int CODE_PAGE_CP737_GREEK = 9;    public static final int CODE_PAGE_WCP1250_LATIN2 = 10;    public static final int CODE_PAGE_WCP1253_GREEK = 11;    public static final int CODE_PAGE_WCP1254_TURKISH = 12;    public static final int CODE_PAGE_CP855_CYRILLIC = 13;    public static final int CODE_PAGE_CP862_HEBREW = 14;    public static final int CODE_PAGE_CP866_CYRILLIC = 15;    public static final int CODE_PAGE_WCP1251_CYRILLIC = 16;    public static final int CODE_PAGE_WCP1255_HEBREW = 17;    public static final int CODE_PAGE_CP928_GREEK = 18;    public static final int CODE_PAGE_CP864_ARABIC = 19;    public static final int CODE_PAGE_CP775_BALTIC = 20;    public static final int CODE_PAGE_WCP1257_BALTIC = 21;    public static final int CODE_PAGE_CP858_LATIN1_EURO = 22;    public static final int PRINTING_TYPE_DIRECT_THERMAL = 100;    public static final int PRINTING_TYPE_THERMAL_TRANSFER = 116;    public static final int MEDIA_TYPE_GAP = 71;    public static final int MEDIA_TYPE_CONTINUOUS = 67;    public static final int MEDIA_TYPE_BLACK_MARK = 66;    public static final int SPEED_25IPS = 0;    public static final int SPEED_30IPS = 1;    public static final int SPEED_40IPS = 2;    public static final int SPEED_50IPS = 3;    public static final int SPEED_60IPS = 4;    public static final int SPEED_70IPS = 5;    public static final int SPEED_80IPS = 6;    public static final int ORIENTATION_TOP_TO_BOTTOM = 84;    public static final int ORIENTATION_BOTTOM_TO_TOP = 66;    public static final int PRINTER_INFORMATION_MODEL_NAME = 0;    public static final int PRINTER_INFORMATION_FIRMWARE_VERSION = 2;    public Printer(Context context, Handler handler, Looper looper) {        Log.i("LabelPrinter", "+++ Label PRINTER +++");        Log.i("LabelPrinter", "+++ SDK VERSION : V1.0.0 +++");        this.mServiceManager = new ServiceManager(context, handler, looper);        this.mContext = context;    }    public void findBluetoothPrinters() {        this.mServiceManager.findBluetoothPrinters();    }    public void connect(String address) {        this.mServiceManager.connect(address);    }    public void connect(String address, int type) {        this.mServiceManager.connect(address, type);    }    public void findNetworkPrinters(int timeout) {        this.mServiceManager.findNetworkPrinters(timeout);    }    public void connect(String host, int port, int timeout) {        this.mServiceManager.connect(host, port, timeout);    }    public void findUsbPrinters() {        this.mServiceManager.findUsbPrinters();    }    public void connect(UsbDevice device) {        this.mServiceManager.connect(device);    }    public void connect() {        this.mServiceManager.connect();    }    public boolean isConnected() {        return this.mServiceManager.isConnected();    }    public void disconnect() {        this.mServiceManager.disconnect();    }    public void print(int set, int copy) {        if (set >= 1 && set <= 65535 && copy >= 1 && copy <= 65535) {            this.mServiceManager.inputPrintJob(("P" + set + "," + copy).getBytes());        }    }    public void drawText(String data, int horizontalPosition, int verticalPosition, int fontSize, int horizontalMultiplier, int verticalMultiplier, int rightSpace, int rotation, boolean reverse, boolean bold, int alignment) {        int fontType = 0;        if (fontSize >= 97 && fontSize < 103) {            fontType = 1;        } else if (fontSize != 109 && fontSize != 110) {            if (fontSize == 106) {                fontType = 3;            }        } else {            fontType = 2;        }        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage(), fontType);        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && horizontalMultiplier >= 1 && horizontalMultiplier <= 6 && verticalMultiplier >= 1 && verticalMultiplier <= 6 && rotation >= 0 && rotation <= 3) {            int capacity = "T".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + 1 + ",".getBytes().length + Integer.toString(horizontalMultiplier).getBytes().length + ",".getBytes().length + Integer.toString(verticalMultiplier).getBytes().length + ",".getBytes().length + Integer.toString(rightSpace).getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + "R".getBytes().length + ",".getBytes().length + "B".getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            if (alignment == 70 || alignment == 76 || alignment == 82) {                capacity += 2;            }            if (rightSpace > 0) {                ++capacity;            }            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("T".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) fontSize);            buffer.put(",".getBytes());            buffer.put(Integer.toString(horizontalMultiplier).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalMultiplier).getBytes());            buffer.put(",".getBytes());            if (rightSpace > 0) {                buffer.put((byte) 67);            } else if (rightSpace < 0) {                buffer.put((byte) 69);            }            buffer.put(Integer.toString(rightSpace).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            if (reverse) {                buffer.put("R".getBytes());            } else {                buffer.put("N".getBytes());            }            buffer.put(",".getBytes());            if (bold) {                buffer.put("B".getBytes());            } else {                buffer.put("N".getBytes());            }            buffer.put(",".getBytes());            if (alignment == 70 || alignment == 76 || alignment == 82) {                buffer.put((byte) alignment);                buffer.put(",".getBytes());            }            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawVectorFontText(String data, int horizontalPosition, int verticalPosition, int font, int width, int height, int rightSpace, boolean bold, boolean reverse, boolean italic, int rotation, int alignment, int direction) {        int fontType = 0;        if (font != 85 && font != 97 && font != 98) {            if (font == 75) {                fontType = 1;            } else if (font != 66 && font != 71) {                if (font == 74) {                    fontType = 3;                }            } else {                fontType = 2;            }        } else {            fontType = 0;        }        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage(), fontType);        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && rotation >= 0 && rotation <= 3 && (direction == 0 || direction == 1)) {            int capacity = "V".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + 1 + ",".getBytes().length + Integer.toString(width).getBytes().length + ",".getBytes().length + Integer.toString(height).getBytes().length + ",".getBytes().length + Integer.toString(rightSpace).getBytes().length + ",".getBytes().length + "B".getBytes().length + ",".getBytes().length + "R".getBytes().length + ",".getBytes().length + "I".getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + Integer.toString(direction).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            if (alignment == 76 || alignment == 82 || alignment == 67) {                capacity += 2;            }            if (rightSpace > 0) {                ++capacity;            }            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("V".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) font);            buffer.put(",".getBytes());            buffer.put(Integer.toString(width).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            if (rightSpace > 0) {                buffer.put((byte) 67);            } else if (rightSpace < 0) {                buffer.put((byte) 69);            }            buffer.put(Integer.toString(rightSpace).getBytes());            buffer.put(",".getBytes());            if (bold) {                buffer.put("B".getBytes());            } else {                buffer.put("N".getBytes());            }            buffer.put(",".getBytes());            if (reverse) {                buffer.put("R".getBytes());            } else {                buffer.put("N".getBytes());            }            buffer.put(",".getBytes());            if (italic) {                buffer.put("I".getBytes());            } else {                buffer.put("N".getBytes());            }            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            if (alignment == 76 || alignment == 82 || alignment == 67) {                buffer.put((byte) alignment);                buffer.put(",".getBytes());            }            buffer.put(Integer.toString(direction).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void draw1dBarcode(String data, int horizontalPosition, int verticalPosition, int barcodeSelection, int narrowBarWidth, int wideBarWidth, int height, int rotation, int hri, int quietZoneWidth) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && barcodeSelection >= 0 && barcodeSelection <= 16 && rotation >= 0 && rotation <= 3 && hri >= 0 && hri <= 8) {            int capacity = "B1".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + Integer.toString(barcodeSelection).getBytes().length + ",".getBytes().length + Integer.toString(narrowBarWidth).getBytes().length + ",".getBytes().length + Integer.toString(wideBarWidth).getBytes().length + ",".getBytes().length + Integer.toString(height).getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + Integer.toString(hri).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            if (quietZoneWidth >= 0 && quietZoneWidth <= 20) {                capacity += Integer.toString(hri).getBytes().length;                capacity += ",".getBytes().length;            }            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B1".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(barcodeSelection).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(narrowBarWidth).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(wideBarWidth).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(hri).getBytes());            buffer.put(",".getBytes());            if (quietZoneWidth >= 0 && quietZoneWidth <= 20) {                buffer.put(Integer.toString(quietZoneWidth).getBytes());                buffer.put(",".getBytes());            }            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawMaxicode(String data, int horizontalPosition, int verticalPosition, int mode) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && (mode == 0 || mode == 2 || mode == 3 || mode == 4)) {            int capacity = "B2".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + "M".getBytes().length + ",".getBytes().length + Integer.toString(mode).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("M".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(mode).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawPdf417(String data, int horizontalPosition, int verticalPosition, int maxRow, int maxColumn, int errorCorrection, int compression, int hri, int originPoint, int width, int height, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && maxRow >= 3 && maxRow <= 90 && maxColumn >= 1 && maxColumn <= 30 && errorCorrection >= 0 && errorCorrection <= 8 && compression >= 0 && compression <= 2 && (hri == 0 || hri == 1) && originPoint >= 0 && originPoint <= 1 && width >= 2 && width <= 9 && height >= 4 && height <= 99 && rotation >= 0 && rotation <= 3) {            int capacity = "B2".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + "P".getBytes().length + ",".getBytes().length + Integer.toString(maxRow).getBytes().length + ",".getBytes().length + Integer.toString(maxColumn).getBytes().length + ",".getBytes().length + Integer.toString(errorCorrection).getBytes().length + ",".getBytes().length + Integer.toString(compression).getBytes().length + ",".getBytes().length + Integer.toString(hri).getBytes().length + ",".getBytes().length + Integer.toString(originPoint).getBytes().length + ",".getBytes().length + Integer.toString(width).getBytes().length + ",".getBytes().length + Integer.toString(height).getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("P".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(maxRow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(maxColumn).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(errorCorrection).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(compression).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(hri).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(originPoint).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(width).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawQrCode(String data, int horizontalPosition, int verticalPosition, int model, int eccLevel, int size, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && model >= 1 && model <= 2 && (eccLevel == 76 || eccLevel == 77 || eccLevel == 81 || eccLevel == 72) && size >= 1 && size <= 9 && rotation >= 0 && rotation <= 3) {            int capacity = "B2".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + "Q".getBytes().length + ",".getBytes().length + Integer.toString(model).getBytes().length + ",".getBytes().length + 1 + ",".getBytes().length + Integer.toString(size).getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("Q".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(model).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) eccLevel);            buffer.put(",".getBytes());            buffer.put(Integer.toString(size).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawDataMatrix(String data, int horizontalPosition, int verticalPosition, int size, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && size >= 1 && size <= 4 && rotation >= 0 && rotation <= 3) {            int capacity = "B2".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + "D".getBytes().length + ",".getBytes().length + Integer.toString(size).getBytes().length + ",".getBytes().length + "R".getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("D".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(size).getBytes());            buffer.put(",".getBytes());            buffer.put("N".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawAztec(String data, int horizontalPosition, int verticalPosition, int size, boolean extendedChannel, int eccLevel, boolean menuSymbol, int numberOfSymbols, String optionalID, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && size >= 1 && size <= 10 && rotation >= 0 && rotation <= 3) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("A".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(size).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (extendedChannel ? 49 : 48));            buffer.put(",".getBytes());            buffer.put(Integer.toString(eccLevel).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (menuSymbol ? 49 : 48));            buffer.put(",".getBytes());            buffer.put(Integer.toString(numberOfSymbols).getBytes());            buffer.put(",".getBytes());            buffer.put(optionalID.getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawCode49(String data, int horizontalPosition, int verticalPosition, int widthNarrow, int widthWide, int height, int hri, int startingMode, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && rotation >= 0 && rotation <= 3) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("F".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthNarrow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthWide).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(hri).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(startingMode).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawCodaBlock(String data, int horizontalPosition, int verticalPosition, int widthNarrow, int widthWide, int height, boolean securityLevel, int dataColumns, char mode, int encode) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("C".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthNarrow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthWide).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (securityLevel ? 49 : 48));            buffer.put(",".getBytes());            buffer.put(Integer.toString(dataColumns).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) mode);            buffer.put(",".getBytes());            buffer.put(Integer.toString(encode).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) 48);            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawMicroPDF417(String data, int horizontalPosition, int verticalPosition, int moduleWidth, int height, int mode, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B2".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("B".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(moduleWidth).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(mode).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawIMBBarcode(String data, int horizontalPosition, int verticalPosition, boolean hri, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B3".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("I".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (hri ? 49 : 48));            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawMSIBarcode(String data, int horizontalPosition, int verticalPosition, int widthNarrow, int widthWide, int height, int checkDigit, boolean printCheckDigit, int hri, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B3".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("M".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthNarrow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthWide).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(checkDigit).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (printCheckDigit ? 49 : 48));            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(hri).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawPlesseyBarcode(String data, int horizontalPosition, int verticalPosition, int widthNarrow, int widthWide, int height, boolean printCheckDigit, int hri, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B3".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("P".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthNarrow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthWide).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put((byte) (printCheckDigit ? 49 : 48));            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(hri).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawTLC39Barcode(String data, int horizontalPosition, int verticalPosition, int widthNarrow, int widthWide, int height, int rowHeightOfMicroPDF417, int narrowWidthOfMicroPDF417, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0) {            ByteBuffer buffer = ByteBuffer.allocate(1024);            buffer.put("B3".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("T".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthNarrow).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(widthWide).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(height).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rowHeightOfMicroPDF417).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(narrowWidthOfMicroPDF417).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            byte[] outBuffer = new byte[buffer.position()];            System.arraycopy(buffer.array(), 0, outBuffer, 0, buffer.position());            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawRSSBarcode(String data, int horizontalPosition, int verticalPosition, int barcodeType, int magnification, int seperator, int BarHeight, int SegmentWidth, int rotation) {        byte[] bytes = CodePageManager.getBytes(data, this.mServiceManager.getCodePage());        byte[] line = new byte[]{13, 10};        if (data != null && data.length() > 0 && barcodeType >= 0 && barcodeType <= 11 && rotation >= 0 && rotation <= 3) {            int capacity = "B3".getBytes().length + Integer.toString(horizontalPosition).getBytes().length + ",".getBytes().length + Integer.toString(verticalPosition).getBytes().length + ",".getBytes().length + "R".getBytes().length + ",".getBytes().length + Integer.toString(barcodeType).getBytes().length + ",".getBytes().length + Integer.toString(magnification).getBytes().length + ",".getBytes().length + Integer.toString(seperator).getBytes().length + ",".getBytes().length + Integer.toString(BarHeight).getBytes().length + ",".getBytes().length + Integer.toString(SegmentWidth).getBytes().length + ",".getBytes().length + Integer.toString(rotation).getBytes().length + ",".getBytes().length + "'".getBytes().length + bytes.length + "'".getBytes().length + line.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("B3".getBytes());            buffer.put(Integer.toString(horizontalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(verticalPosition).getBytes());            buffer.put(",".getBytes());            buffer.put("R".getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(barcodeType).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(magnification).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(seperator).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(BarHeight).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(SegmentWidth).getBytes());            buffer.put(",".getBytes());            buffer.put(Integer.toString(rotation).getBytes());            buffer.put(",".getBytes());            buffer.put("'".getBytes());            buffer.put(bytes);            buffer.put("'".getBytes());            buffer.put(line);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void drawBlock(int horizontalStartPosition, int verticalStartPosition, int horizontalEndPosition, int verticalEndPosition, int option, int thickness) {        if (option == 79 || option == 69 || option == 68 || option == 83 || option == 66) {            StringBuffer buffer = new StringBuffer("BD");            buffer.append(horizontalStartPosition);            buffer.append(",");            buffer.append(verticalStartPosition);            buffer.append(",");            buffer.append(horizontalEndPosition);            buffer.append(",");            buffer.append(verticalEndPosition);            buffer.append(",");            buffer.append(Character.toChars(option));            if (option == 83 || option == 66) {                buffer.append(",");                buffer.append(thickness);            }            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void drawTowBlock(int horizontalStartPosition, int verticalStartPosition, int horizontalEndPosition, int verticalEndPosition, int option, int horizontalStartPositionSquare2, int verticalStartPositionSquare2, int horizontalEndPositionSquare2, int verticalEndPositionSquare2, int optionSquare2) {        StringBuffer buffer = new StringBuffer("BD");        buffer.append(horizontalStartPosition);        buffer.append(",");        buffer.append(verticalStartPosition);        buffer.append(",");        buffer.append(horizontalEndPosition);        buffer.append(",");        buffer.append(verticalEndPosition);        buffer.append(",");        buffer.append(Character.toChars(option));        buffer.append(",");        buffer.append(Command.TERMINATER);        buffer.append("BD");        buffer.append(horizontalStartPositionSquare2);        buffer.append(",");        buffer.append(verticalStartPositionSquare2);        buffer.append(",");        buffer.append(horizontalEndPositionSquare2);        buffer.append(",");        buffer.append(verticalEndPositionSquare2);        buffer.append(",");        buffer.append(Character.toChars(optionSquare2));        this.mServiceManager.inputPrintJob(buffer.toString().getBytes());    }    public void drawCircle(int horizontalStartPosition, int verticalStartPosition, int size, int multiplier) {        if (size >= 1 && size <= 6 && multiplier >= 1 && multiplier <= 4) {            StringBuffer buffer = new StringBuffer("CD");            buffer.append(horizontalStartPosition);            buffer.append(",");            buffer.append(verticalStartPosition);            buffer.append(",");            buffer.append(size);            buffer.append(",");            buffer.append(multiplier);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setCharacterSet(int internationalCharacterSet, int codePage) {        if (internationalCharacterSet >= 0 && internationalCharacterSet <= 15 && codePage >= 0 && codePage <= 22) {            StringBuffer buffer = new StringBuffer("CS");            buffer.append(internationalCharacterSet);            buffer.append(",");            buffer.append(codePage);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());            this.mServiceManager.setCodePage(codePage);        }    }    public void setPrintingType(int type) {        if (type == 100 || type == 116) {            StringBuffer buffer = new StringBuffer("ST");            buffer.append(Character.toChars(type));            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setMargin(int horizontalMargin, int verticalMargin) {        StringBuffer buffer = new StringBuffer("SM");        buffer.append(horizontalMargin);        buffer.append(",");        buffer.append(verticalMargin);        this.mServiceManager.inputPrintJob(buffer.toString().getBytes());    }    public void setBackFeedOption(boolean enabled, int quantity) {        StringBuffer buffer = new StringBuffer("SF");        if (enabled) {            buffer.append(1);            buffer.append(",");            buffer.append(quantity);        } else {            buffer.append(0);        }        this.mServiceManager.inputPrintJob(buffer.toString().getBytes());    }    public void setLength(int labelLength, int gapLength, int mediaType, int offsetLength) {        if (labelLength > 0 && (mediaType == 71 || mediaType == 67 || mediaType == 66)) {            StringBuffer buffer = new StringBuffer("SL");            buffer.append(labelLength);            buffer.append(",");            buffer.append(gapLength);            buffer.append(",");            buffer.append(Character.toChars(mediaType));            buffer.append(",");            if (offsetLength > 0) {                buffer.append(offsetLength);            }            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setWidth(int labelWidth) {        if (labelWidth > 0) {            StringBuffer buffer = new StringBuffer("SW");            buffer.append(labelWidth);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setBufferMode(boolean doubleBuffering) {        StringBuffer buffer = new StringBuffer("SB");        if (doubleBuffering) {            buffer.append(1);        } else {            buffer.append(0);        }        this.mServiceManager.inputPrintJob(buffer.toString().getBytes());    }    public void clearBuffer() {        this.mServiceManager.inputPrintJob("CB".getBytes());    }    public void setSpeed(int speed) {        if (speed >= 0 && speed <= 6) {            StringBuffer buffer = new StringBuffer("SS");            buffer.append(speed);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setDensity(int density) {        if (density > 0) {            StringBuffer buffer = new StringBuffer("SD");            buffer.append(density);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setOrientation(int orientation) {        if (orientation == 84 || orientation == 66) {            StringBuffer buffer = new StringBuffer("SO");            buffer.append(Character.toChars(orientation));            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setOffset(int offset) {        if (offset >= -100 && offset <= 100) {            StringBuffer buffer = new StringBuffer("SA");            buffer.append(offset);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void setCutterPosition(int position) {        if (position >= -100 && position <= 100) {            StringBuffer buffer = new StringBuffer("TA");            buffer.append(position);            this.mServiceManager.inputPrintJob(buffer.toString().getBytes());        }    }    public void drawBitmap(String pathName, int horizontalStartPosition, int verticalStartPosition, int width, int level, boolean dithering) {        if (pathName != null && pathName.length() > 0) {            Options opts = new Options();            opts.inJustDecodeBounds = false;            opts.inSampleSize = 1;            opts.inPreferredConfig = Config.RGB_565;            try {                Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);                this.drawBitmap(bitmap, horizontalStartPosition, verticalStartPosition, width, level, dithering);            } catch (OutOfMemoryError var10) {                opts.inSampleSize = 2;                Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);                this.drawBitmap(bitmap, horizontalStartPosition, verticalStartPosition, width, level, dithering);            }        }    }    public void drawBitmap(Bitmap bitmap, int horizontalStartPosition, int verticalStartPosition, int width, int level, boolean dithering) {        if (bitmap != null) {            byte[] data = BitmapManager.bitmap2printerData(bitmap, width, level, false, dithering);            int height = BitmapManager.getBitmapHeight(bitmap, width);            int bytesOfWidth = width % 8 == 0 ? width / 8 : width / 8 + 1;            int capacity = "LD".length() + 8 + data.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("LD".getBytes());            buffer.put((byte) (horizontalStartPosition % 256));            buffer.put((byte) (horizontalStartPosition / 256));            buffer.put((byte) (verticalStartPosition % 256));            buffer.put((byte) (verticalStartPosition / 256));            buffer.put((byte) (bytesOfWidth % 256));            buffer.put((byte) (bytesOfWidth / 256));            buffer.put((byte) (height % 256));            buffer.put((byte) (height / 256));            buffer.put(data);            this.mServiceManager.inputPrintJob2(buffer.array());        }    }    public void drawBitmap(byte[] data, int horizontalStartPosition, int verticalStartPosition, int width, int level, boolean dithering) {        int height = 1000;        int bytesOfWidth = width % 8 == 0 ? width / 8 : width / 8 + 1;        int capacity = "LD".length() + 8 + data.length;        ByteBuffer buffer = ByteBuffer.allocate(capacity);        buffer.put("LD".getBytes());        buffer.put((byte) (horizontalStartPosition % 256));        buffer.put((byte) (horizontalStartPosition / 256));        buffer.put((byte) (verticalStartPosition % 256));        buffer.put((byte) (verticalStartPosition / 256));        buffer.put((byte) (bytesOfWidth % 256));        buffer.put((byte) (bytesOfWidth / 256));        buffer.put((byte) (height % 256));        buffer.put((byte) (height / 256));        buffer.put(data);        this.mServiceManager.inputPrintJob(buffer.array());    }    public void beginTransactionPrint() {        if (!this.mServiceManager.transactionPrint) {            this.mServiceManager.transactionPrint = true;        }    }    public void endTransactionPrint() {        if (this.mServiceManager.transactionPrint) {            this.mServiceManager.executeCommand(9, 0);            this.mServiceManager.transactionPrint = false;        }    }    public void drawCompressionImage(String pathName, int horizontalStartPosition, int verticalStartPosition, int width, int level, int rotate) {        if (pathName != null && pathName.length() > 0) {            Bitmap bitmap = BitmapManager.loadImage(pathName, rotate);            if (bitmap != null) {                byte[] data = BitmapManager.bitmap2printerData(bitmap, width, level, false, true);                int height = BitmapManager.getBitmapHeight(bitmap, width);                byte[] compressedData = RunLengthEncoding.encode(data, width, height);                int bytesOfWidth = width % 8 == 0 ? width / 8 : width / 8 + 1;                int capacity = "LC".length() + "R".length() + 1 + 8 + compressedData.length;                ByteBuffer buffer = ByteBuffer.allocate(capacity);                buffer.put("LC".getBytes());                buffer.put("R".getBytes());                buffer.put((byte) 0);                buffer.put((byte) (horizontalStartPosition % 256));                buffer.put((byte) (horizontalStartPosition / 256));                buffer.put((byte) (verticalStartPosition % 256));                buffer.put((byte) (verticalStartPosition / 256));                buffer.put((byte) (bytesOfWidth % 256));                buffer.put((byte) (bytesOfWidth / 256));                buffer.put((byte) (height % 256));                buffer.put((byte) (height / 256));                buffer.put(compressedData);                this.mServiceManager.inputPrintJob(buffer.array());            }        }    }    public void drawCompressionImage(String pathName, int horizontalStartPosition, int verticalStartPosition, int width, int level, boolean dithering) {        if (pathName != null && pathName.length() > 0) {            Options opts = new Options();            opts.inJustDecodeBounds = false;            opts.inSampleSize = 1;            opts.inPreferredConfig = Config.RGB_565;            try {                Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);                this.drawCompressionImage(bitmap, horizontalStartPosition, verticalStartPosition, width, level, dithering);            } catch (OutOfMemoryError var10) {                opts.inSampleSize = 2;                Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);                this.drawCompressionImage(bitmap, horizontalStartPosition, verticalStartPosition, width, level, dithering);            }        }    }    public void drawCompressionImage(Bitmap bitmap, int horizontalStartPosition, int verticalStartPosition, int width, int level, boolean dithering) {        if (bitmap != null) {            byte[] data = BitmapManager.bitmap2printerData(bitmap, width, level, false, dithering);            int height = BitmapManager.getBitmapHeight(bitmap, width);            byte[] compressedData = RunLengthEncoding.encode(data, width, height);            int bytesOfWidth = width % 8 == 0 ? width / 8 : width / 8 + 1;            int capacity = "LC".length() + "R".length() + 1 + 8 + compressedData.length;            ByteBuffer buffer = ByteBuffer.allocate(capacity);            buffer.put("LC".getBytes());            buffer.put("R".getBytes());            buffer.put((byte) 0);            buffer.put((byte) (horizontalStartPosition % 256));            buffer.put((byte) (horizontalStartPosition / 256));            buffer.put((byte) (verticalStartPosition % 256));            buffer.put((byte) (verticalStartPosition / 256));            buffer.put((byte) (bytesOfWidth % 256));            buffer.put((byte) (bytesOfWidth / 256));            buffer.put((byte) (height % 256));            buffer.put((byte) (height / 256));            buffer.put(compressedData);            this.mServiceManager.inputPrintJob(buffer.array());        }    }    public void initializePrinter() {        this.mServiceManager.inputPrintJob("@".getBytes());    }    public void printInformation() {        this.mServiceManager.inputPrintJob("^PI0".getBytes());//        this.mServiceManager.inputPrintJob("PI".getBytes());    }    public void setAutoCutter(boolean enabled, int cuttingPeriod) {        if (enabled) {            String out = "CUTy";            if (cuttingPeriod > 0) {                out = out + "," + cuttingPeriod;            }            this.mServiceManager.inputPrintJob(out.getBytes());        } else {            this.mServiceManager.executeCommand("CUTn", false);        }    }    public void setRewinder(boolean enabled) {        if (enabled) {            this.mServiceManager.inputPrintJob("RWDy".getBytes());        } else {            this.mServiceManager.inputPrintJob("RWDn".getBytes());        }    }    public void getStatus(boolean checkImageBuffer) {        if (checkImageBuffer) {            this.mServiceManager.executeCommand(4, 0);        } else {            this.mServiceManager.executeCommand(3, 0);        }    }    public void getPrinterInformation(int param) {        if (param == 0) {            this.mServiceManager.executeCommand(5, 0);        } else if (param == 2) {            this.mServiceManager.executeCommand(6, 0);        }    }    public void executeDirectIo(String command, boolean hasResponse, int responseLength) {        byte[] bytes = CodePageManager.getBytes(command, this.mServiceManager.getCodePage());        this.executeDirectIo(bytes, hasResponse, responseLength);    }    public void executeDirectIo(byte[] command, boolean hasResponse, int responseLength) {        if (hasResponse) {            this.mServiceManager.setResponseLength(responseLength);            this.mServiceManager.executeCommand(7, command);        } else {            this.mServiceManager.executeCommand(command, false);        }    }    public static void saveBinary(byte[] hex) {        if (isSaveBinary) {            String dir = Environment.getExternalStorageDirectory() + "/sato";            Log.e(TAG, "saveBinary>dir:" + dir);            File file = new File(dir + "/sato_sdk" + ".bin");            boolean append = file.exists();            if (!(new File(dir)).exists()) {                (new File(dir)).mkdir();            }            if (!file.exists()) {                try {                    file.createNewFile();                } catch (IOException var6) {                    var6.printStackTrace();                }            }            try {                FileOutputStream fileOutputStream = new FileOutputStream(file, append);                fileOutputStream.write(hex);                fileOutputStream.close();            } catch (IOException var5) {                var5.printStackTrace();            }        }    }    public void setLeftMarginPosition(int shiftVal) {        ByteBuffer buffer = ByteBuffer.allocate(6);        buffer.put((byte) 27);        buffer.put((byte) 25);        buffer.put((byte) 25);        buffer.put((byte) 15);        buffer.put((byte) shiftVal);        if (shiftVal >= 0) {            buffer.put((byte) 0);        } else {            buffer.put((byte) -1);        }        Log.i("LabelPrinter", "++ setLeftPosition(" + buffer.array() + ")");        this.executeDirectIo((byte[]) buffer.array(), false, 0);    }    public void setSaveBinary(boolean isSave) {        isSaveBinary = isSave;    }    public boolean getSaveBinary() {        return isSaveBinary;    }}